
/**
 * 路由导航简写newVueRouter
 */
import Vue from 'vue';
import VueRouter from 'vue-router';
// head进度条,导入进度条样式
import 'nprogress/nprogress.css'
import { start, done, configure } from 'nprogress';
// 配置进度条
configure({
    trickleSpeed: 20,//设置进度条速度
    showSpinner: false,//不显示右侧小圈圈
})

if (!window.VueRouter) {
    Vue.use(VueRouter);
}
const router = new VueRouter({
    base: '/',
    mode: 'history',
    routes: [
        {
            name: 'Home', path: '/', component: async () => {
                start();
                const comp = await import('@/views/Home');
                done();
                return comp
            }, meta: { title: '首页' }
        },
        { name: 'Blog', path: '/Blog', component: () => import('@/views/Blog'), meta: { title: '文章' } },
        //动态路由，匹配指定分页内容
        { name: 'categoryId', path: '/Blog/cate/:categoryId', component: () => import('@/views/Blog'), meta: { title: '文章' } },
        //匹配文章博客主题
        { name: 'BlogBody', path: '/Blog/:id', component: () => import('@/views/Blog/BlogBody'), meta: { title: '文章详情' } },
        {name: 'About', path: '/About', component: () => import('@/views/About'), meta: { title: '关于我' },},
        {name: 'Project', path: '/Project', component: () => import('@/views/Project'), meta: { title: '项目&效果' },},
        {
            name: 'meituan', path: '/Project/meituan', component: () => import('../views/meituan'), meta: { title: '美团' }, children: [{
                name: "Index",
                path: "Index",
                component: () =>
                    import('../views/About/views/main/index.vue'),
                meta: { title: '美团首页' }
            },
            {name:'changeCity',path:'changeCity',component:()=>import('../views/meituan/views/main/changeCity.vue'),meta:'切换城市'},
        ]
        }, {
            name: 'meiriyouxian', path: '/Project/meiriyouxian', component: () => import('../views/meiriyouxian'), meta: { title: '每日优鲜' }
        },
        { name: 'Message', path: '/Message', component: () => import('@/views/Message'), meta: { title: '留言板' } },
        { name: 'NoFounnd', path: '*', component: () => import('@/components/NoFound'), }

    ],
});
export default router;
// 确认之后简写afterEach
//路由标题依托于导航首位
// 路由却之前
import setTitle from '../utils/siteTitlle'
router.afterEach((to, from) => {
    if (to.meta.title) {
        setTitle.setRouterTitle(to.meta.title);

    }

});